home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / doom / quake_ad.zip / HIPQW.ZIP / SRC / HIPSPAWN.QC < prev    next >
Text File  |  1997-02-10  |  10KB  |  364 lines

  1. //=====================================================================
  2. //
  3. // Spawning Functions (Hipnotic)
  4. //
  5. //=====================================================================
  6.  
  7. //================
  8. //
  9. // spawn_think
  10. //
  11. //================
  12.  
  13. void() spawn_think =
  14.    {
  15.    self.think = spawn_think;
  16.    self.nextthink = time + 1;
  17.    };
  18.  
  19. //================
  20. //
  21. // spawn_use
  22. //
  23. //================
  24.  
  25. void() spawn_use =
  26.    {
  27.    local entity spawnentity;
  28.    local entity tempself;
  29.  
  30.    if ((self.spawnmulti == 1) || (horn_active))
  31.       {
  32.       // spawn the new entity
  33.       spawnentity = spawn();
  34.       // copy the master mold
  35.       SUB_CopyEntity(self.spawnmaster,spawnentity);
  36.       }
  37.    else
  38.       {
  39.       spawnentity = self.spawnmaster;
  40.       }
  41.    // restore the model
  42.    spawnentity.model = spawnentity.spawnmodel;
  43.    //restore solid flag
  44.    spawnentity.solid = spawnentity.spawnsolidtype;
  45.    //restore thinking function
  46.    spawnentity.think = spawnentity.spawnthink;
  47.    setmodel (spawnentity, spawnentity.model);
  48.    setorigin (spawnentity, spawnentity.origin);
  49.    spawnentity.mins = spawnentity.spawnmins;
  50.    spawnentity.maxs = spawnentity.spawnmaxs;
  51.    setsize (spawnentity, spawnentity.mins, spawnentity.maxs);
  52.    // spawn the teleport effect
  53.    if (self.spawnsilent == 0)
  54.       spawn_tfog (spawnentity.origin);
  55. //   horn_active = 0;
  56. //   horn_charmer = find( world, classname, "player" );
  57.    // call spawnentity think function
  58.    if (horn_active)
  59.       {
  60.       spawnentity.charmer = horn_charmer;
  61.       spawnentity.charmed = 1;
  62.       }
  63. //   if (spawnentity.think)
  64. //      {
  65. //      spawnentity.nextthink = time+0.1;
  66. //      tempself = self;
  67. //      self = spawnentity;
  68. //      self.think();
  69. //      self = tempself;
  70. //      spawnentity.nextthink = time+0.1;
  71. //      self.nextthink = 1;
  72. //      if (spawnentity.nextthink < time)
  73. //         spawnentity.nextthink = 1;
  74. //      }
  75.    // check to see if it is a monster
  76.    if (spawnentity.flags & FL_MONSTER)
  77.       {
  78.       if ((self.spawnmulti != 0) && (horn_active == 0))
  79.          {
  80.          total_monsters = total_monsters + 1;
  81.          WriteByte (MSG_BROADCAST, SVC_UPDATESTAT);
  82.          WriteByte (MSG_BROADCAST, STAT_TOTALMONSTERS);
  83.          WriteLong (MSG_BROADCAST, total_monsters);
  84.          }
  85.       // spawn the telefrag effect
  86. //      if (self.spawnsilent == 0)
  87. //         spawn_tdeath(spawnentity.origin, spawnentity);
  88.       if (horn_active)
  89.          {
  90.          spawnentity.effects = spawnentity.effects | EF_DIMLIGHT;
  91. //         spawnentity.effects = spawnentity.effects | EF_BRIGHTFIELD;
  92.          }
  93.       }
  94.    if ((self.spawnmulti == 0) && (horn_active == 0))
  95.       {
  96.       remove(self);
  97.       }
  98.    };
  99.  
  100. //================
  101. //
  102. // func_spawn
  103. //
  104. //================
  105. /*QUAKED func_spawn (0 .5 .8) (-32 -32 -24) (32 32 64) big/ambush megahealth
  106. This will spawn a thing upon being used. The thing that
  107. is spawned depends upon the value of "spawnfunction".
  108. "spawnclassname" should contain the same value as "spawnfunction".
  109. If "spawnfunction" is unspecified a random monster is chosen.
  110. The angles, target and all flags are passed on
  111. Think of it like setting up a normal entity.
  112. "spawnsilent" set this to 1 if you want a silent spawn.
  113. "spawnmulti" set this to 1 if you want this spawn to be reoccuring.
  114. */
  115.  
  116. void() func_spawn =
  117.    {
  118.    local entity tempself;
  119.    local entity monster;
  120.    local float tempdeathmatch;
  121.    local float temptotal_monsters;
  122.    local vector mn,mx;
  123.  
  124. //   if (deathmatch)
  125. //   {
  126. //      remove(self);
  127. //      return;
  128. //   }
  129.  
  130.    // save off deathmatch and zero it out
  131.    tempself = self;
  132.    tempdeathmatch = deathmatch;
  133.    deathmatch = 0;
  134.    if (!self.spawnfunction)
  135.       {
  136.       local float spawnchance;
  137.  
  138.       spawnchance = random();
  139.       monster = tempself;
  140.  
  141.       // save off monster count so it doesn't get f'ed up
  142.       temptotal_monsters = total_monsters;
  143.  
  144.       // spawn dog
  145.       // spawn the new entity
  146.       self = spawn();
  147.       // copy over everything
  148.       SUB_CopyEntity(tempself,self);
  149.       self.spawnfunction = monster_dog;
  150.       self.spawnclassname = "monster_dog";
  151.       self.classname = self.spawnclassname;
  152.  
  153.       // call the named spawn function
  154.       self.spawnfunction();
  155.       self.spawnmodel = self.model;
  156.       self.spawnmins = self.mins;
  157.       self.spawnmaxs = self.maxs;
  158.       setmodel (self, "");
  159.       setsize (self, self.spawnmins, self.spawnmaxs);
  160.       //save off solid flag
  161.       self.spawnsolidtype = self.solid;
  162.       self.solid = SOLID_NOT;
  163.       //save off think func and
  164.       //get rid of his thinking
  165.       self.spawnthink = self.think;
  166.       self.think = spawn_think;
  167.       self.nextthink = time + 1;
  168.  
  169.       if (spawnchance<0.5 && monster==tempself)
  170.          {
  171.          monster = self;
  172.          }
  173.  
  174.       // spawn ogre
  175.       // spawn the new entity
  176.       self = spawn();
  177.       // copy over everything
  178.       SUB_CopyEntity(tempself,self);
  179.       self.spawnfunction = monster_ogre;
  180.       self.spawnclassname = "monster_ogre";
  181.       self.classname = self.spawnclassname;
  182.  
  183.       // call the named spawn function
  184.       self.spawnfunction();
  185.       self.spawnmodel = self.model;
  186.       self.spawnmins = self.mins;
  187.       self.spawnmaxs = self.maxs;
  188.       setmodel (self, "");
  189.       setsize (self, self.spawnmins, self.spawnmaxs);
  190.       //save off solid flag
  191.       self.spawnsolidtype = self.solid;
  192.       self.solid = SOLID_NOT;
  193.       //save off think func and
  194.       //get rid of his thinking
  195.       self.spawnthink = self.think;
  196.       self.think = spawn_think;
  197.       self.nextthink = time + 1;
  198.  
  199.       if (spawnchance<0.8 && monster==tempself)
  200.          {
  201.          monster = self;
  202.          }
  203.  
  204.       // spawn fiend
  205.       // spawn the new entity
  206.       self = spawn();
  207.       // copy over everything
  208.       SUB_CopyEntity(tempself,self);
  209.       self.spawnfunction = monster_demon1;
  210.       self.spawnclassname = "monster_demon1";
  211.       self.classname = self.spawnclassname;
  212.  
  213.       // call the named spawn function
  214.       self.spawnfunction();
  215.       self.spawnmodel = self.model;
  216.       self.spawnmins = self.mins;
  217.       self.spawnmaxs = self.maxs;
  218.       setmodel (self, "");
  219.       setsize (self, self.spawnmins, self.spawnmaxs);
  220.       //save off solid flag
  221.       self.spawnsolidtype = self.solid;
  222.       self.solid = SOLID_NOT;
  223.       //save off think func and
  224.       //get rid of his thinking
  225.       self.spawnthink = self.think;
  226.       self.think = spawn_think;
  227.       self.nextthink = time + 1;
  228.  
  229.       if (spawnchance<0.92 && monster==tempself)
  230.          {
  231.          monster = self;
  232.          }
  233.  
  234.       // spawn zombie
  235.       // spawn the new entity
  236.       self = spawn();
  237.       // copy over everything
  238.       SUB_CopyEntity(tempself,self);
  239.       self.spawnfunction = monster_zombie;
  240.       self.spawnclassname = "monster_zombie";
  241.       self.classname = self.spawnclassname;
  242.  
  243.       // call the named spawn function
  244.       self.spawnfunction();
  245.       self.spawnmodel = self.model;
  246.       self.spawnmins = self.mins;
  247.       self.spawnmaxs = self.maxs;
  248.       setmodel (self, "");
  249.       setsize (self, self.spawnmins, self.spawnmaxs);
  250.       //save off solid flag
  251.       self.spawnsolidtype = self.solid;
  252.       self.solid = SOLID_NOT;
  253.       //save off think func and
  254.       //get rid of his thinking
  255.       self.spawnthink = self.think;
  256.       self.think = spawn_think;
  257.       self.nextthink = time + 1;
  258.  
  259.       if (spawnchance<0.97 && monster==tempself)
  260.          {
  261.          monster = self;
  262.          }
  263.  
  264.       // spawn shambler
  265.       // spawn the new entity
  266.       self = spawn();
  267.       // copy over everything
  268.       SUB_CopyEntity(tempself,self);
  269.       self.spawnfunction = monster_shambler;
  270.       self.spawnclassname = "monster_shambler";
  271.       self.classname = self.spawnclassname;
  272.  
  273.       // call the named spawn function
  274.       self.spawnfunction();
  275.       self.spawnmodel = self.model;
  276.       self.spawnmins = self.mins;
  277.       self.spawnmaxs = self.maxs;
  278.       setmodel (self, "");
  279.       setsize (self, self.spawnmins, self.spawnmaxs);
  280.       //save off solid flag
  281.       self.spawnsolidtype = self.solid;
  282.       self.solid = SOLID_NOT;
  283.       //save off think func and
  284.       //get rid of his thinking
  285.       self.spawnthink = self.think;
  286.       self.think = spawn_think;
  287.       self.nextthink = time + 1;
  288.  
  289.       if (monster==tempself)
  290.          {
  291.          monster = self;
  292.          }
  293.       // make sure monster count is correct
  294.       total_monsters = temptotal_monsters + 1;
  295.       }
  296.    else
  297.       {
  298.       // spawn the new entity
  299.       self = spawn();
  300.       // copy over everything
  301.       SUB_CopyEntity(tempself,self);
  302.  
  303.       // save off monster count so it doesn't get f'ed up
  304.       temptotal_monsters = total_monsters;
  305.       if (self.spawnclassname == string_null)
  306.          {
  307.          objerror("No spawnclassname defined");
  308.          }
  309.       self.classname = self.spawnclassname;
  310.       // call the named spawn function
  311.       self.spawnfunction();
  312.       if (self.spawnmulti != 0)
  313.          {
  314.          // make sure monster count is correct
  315.          total_monsters = temptotal_monsters;
  316.          }
  317.       self.spawnmodel = self.model;
  318.       self.spawnmins = self.mins;
  319.       self.spawnmaxs = self.maxs;
  320.       setmodel (self, "");
  321.       self.model = "";
  322.       setsize (self, self.spawnmins, self.spawnmaxs);
  323.       //save off solid flag
  324.       self.spawnsolidtype = self.solid;
  325.       self.solid = SOLID_NOT;
  326.       //save off think func and
  327.       //get rid of his thinking
  328.       self.spawnthink = self.think;
  329.       self.think = spawn_think;
  330.       self.nextthink = time + 1;
  331.       monster = self;
  332.       }
  333.    self = tempself;
  334.    deathmatch = tempdeathmatch;
  335.    self.solid = SOLID_NOT;
  336.    self.movetype = MOVETYPE_NONE;
  337.     self.modelindex = 0;
  338.     self.model = "";
  339.    setmodel (self, self.model);  // set size and link into world
  340.    self.use = spawn_use;
  341.    self.spawnmaster = monster;
  342.    };
  343.  
  344. //================
  345. //
  346. // func_spawn_small
  347. //
  348. //================
  349. /*QUAKED func_spawn_small (0 .5 .8) (-16 -16 -24) (16 16 40) big/ambush megahealth
  350. This will spawn a thing upon being used. The thing that
  351. is spawned depends upon the value of "spawnfunction".
  352. "spawnclassname" should contain the same value as "spawnfunction".
  353. If "spawnfunction" is unspecified a random monster is chosen.
  354. The angles, target and all flags are passed on
  355. Think of it like setting up a normal entity.
  356. "spawnsilent" set this to 1 if you want a silent spawn.
  357. "spawnmulti" set this to 1 if you want this spawn to be reoccuring.
  358. */
  359.  
  360. void() func_spawn_small =
  361.    {
  362.    func_spawn();
  363.    };
  364.